using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spinning.Spinning.Entity;
using Spinning.Spinning.Unitity;
using Microsoft.Xna.Framework;

namespace Spinning.Spinning.UI
{
    class EnemyBar : BaseEntity
    {
        AnimationSprite name;
        public Constants.PlayerId Player { get; set; }
        public SpeedBar SpeedBar { get; set; }
        SingleGamePlayer _boss;

        public EnemyBar()
        {
            ZIndex = Constants.ui;
            Player = Constants.PlayerId.Phi;
        }

        public EnemyBar(SingleGamePlayer boss)
        {
            ZIndex = Constants.ui;
            _boss = boss;
            if (_boss.Attack_Type == SingleGamePlayer.AttackType.Fire) Player = Constants.PlayerId.Phi;
            if (_boss.Attack_Type == SingleGamePlayer.AttackType.Water) Player = Constants.PlayerId.Theta;
            if (_boss.Attack_Type == SingleGamePlayer.AttackType.Wind) Player = Constants.PlayerId.Omega;
        }

        public override void OnLoad()
        {
            base.OnLoad();
            name = new AnimationSprite();
            name.textureName = "StatusBar/txt";
            name.OnLoad();
            name.SetAnimation(new Point(2, 2));
            Attach(name);
            name.SetChangeFrameAnimation(new int[] { 0 });

            SpeedBar = new SpeedBar();
            SpeedBar.OnLoad();
            SpeedBar.Position = new Vector2(0,25);
            SpeedBar.BackSize = new Vector2(125,15);
            Attach(SpeedBar);
        }

        protected override void DrawSelf(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, GameTime gameTime)
        {
            base.DrawSelf(spriteBatch, gameTime);
            Matrix p = Projection;
        }

        protected override void UpdateSelf(Microsoft.Xna.Framework.GameTime gameTime)
        {
            base.UpdateSelf(gameTime);
            if (_boss != null)
            {
                SpeedBar.Value = _boss.LifeTime;
            }
            switch (Player)
            {
                case Constants.PlayerId.Omega:
                    name.SetChangeFrameAnimation(new int[] { 0 });
                    SpeedBar.speedColor = new Color(255, 135, 0);
                    break;
                case Constants.PlayerId.Phi:
                    name.SetChangeFrameAnimation(new int[] { 1 });
                    SpeedBar.speedColor = Color.Red;
                    break;
                case Constants.PlayerId.Theta:
                    name.SetChangeFrameAnimation(new int[] { 2 });
                    SpeedBar.speedColor = Color.Blue;
                    break;
            }

        }

    }
}
